Skip to content

fix(hub): advertise SSE path relative to connection meta - #519

Open
webfansplz wants to merge 1 commit into
devframes:mainfrom
webfansplz:fix/hub-sse-relative-path
Open

webfansplz wants to merge 1 commit into
devframes:mainfrom
webfansplz:fix/hub-sse-relative-path

Conversation

@webfansplz

Copy link
Copy Markdown
Member

Description

initHub advertises a root-absolute SSE path in __connection.json, such as /__devframes/__sse. When the hub is served behind a path prefix, the client resolves that path against the meta URL and loses the prefix:

meta:   /foo/__devframes/__connection.json
before: /__devframes/__sse
after:  /foo/__devframes/__sse

The SSE request then fails, or reaches another hub if one is running at the root. On Bun, this can break the default connection, since the hub advertises SSE instead of WebSocket when it shares the host's HTTP server.

This PR makes the SSE path relative to each served __connection.json: __sse for the hub and ../__sse for frames mounted under it. The client already resolves the path this way, so it needs no changes.

Additional context

  • connectionMeta() still returns the absolute path, because custom hosts may serve that object from other directories.
  • The WebSocket path is unchanged. Clients that default to WebSocket can still fail behind a proxy that only forwards the prefix.

Tested through Vite DevTools with Node and Bun servers, both behind a proxy that only forwards /foo/ and in a nested setup where the parent strips the prefix. SSE connections from the hub meta now reach the right hub in all of these cases.

Related: vitejs/devtools#662

Copilot AI balanced review requested due to automatic review settings December 3, 2026 06:40
@vercel

vercel Bot commented Dec 3, 2026

Copy link
Copy Markdown

@webfansplz is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the SSE discovery changes intended to preserve proxy prefixes.

No open issues 🎉

What changed in this PR

Fixes hub SSE discovery behind path-prefixed proxies by making advertised paths relative to each served __connection.json.

Changes:

  • Uses relative SSE paths for hub and frame metadata, preserving proxy prefixes.
  • Leaves connectionMeta() and WebSocket paths unchanged.
  • Adds regression coverage for hub and frame URL resolution.
File Description
packages/​hub/​src/​node/​initiate.ts Converts SSE paths to relative paths when serving metadata.
packages/​hub/​src/​node/​__tests__/​initiate.test.ts Tests SSE resolution with a stripped proxy prefix.

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants